    /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mx.edu.itesm.daai.listeners;

import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;


/**
 * Web application lifecycle listener.
 * @author Asrid
 */

public class CCMVirtualListener implements HttpSessionListener, HttpSessionAttributeListener {

    public void sessionCreated(HttpSessionEvent arg0) {
        java.util.Calendar fecha = java.util.Calendar.getInstance();
        long time = arg0.getSession().getCreationTime();
        fecha.setTimeInMillis(time);
        String date = (fecha.get(java.util.Calendar.YEAR)) +"-"+  (fecha.get(java.util.Calendar.MONTH))+"-"+ 
                (fecha.get(java.util.Calendar.DATE))+" "+ (fecha.get(java.util.Calendar.HOUR_OF_DAY))+":"+(fecha.get(java.util.Calendar.MINUTE));
        System.out.println("SESSION CREATED AT: "+date);
        
    }

    public void sessionDestroyed(HttpSessionEvent arg0) {
        System.out.println("SESSION DESTROYED");
    }

    public void attributeAdded(HttpSessionBindingEvent arg0) {
       String s = arg0.getName();
      
       System.out.println("ATTRIBUTE ADDED" +s);
    }

    public void attributeRemoved(HttpSessionBindingEvent arg0) {
        System.out.println("ATTRIBUTE REMOVED");
    }

    public void attributeReplaced(HttpSessionBindingEvent arg0) {
        System.out.println("ATTRIBUTE REPLACE");
    }
}